package chuangyi.com.org.ViewModel;

import android.content.Context;
import android.databinding.Bindable;
import android.support.annotation.LayoutRes;
import android.view.View;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Keep;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.Transient;

import chuangyi.com.org.DOMIHome.adapter.BindingListItem;

import org.greenrobot.greendao.annotation.Generated;

/**
 * Created by zxh on 16/12/11.
 */
@Entity
public class SearchRecord extends BindingListItem {
    @Id(autoincrement = true)
    private Long id;
    @Property(nameInDb = "text")
    private String text;
    @Property(nameInDb = "timestamp")
    private long timestamp;
    @Transient
    private int no;
    @Transient
    private SearchModel parent;

    @Bindable
    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    @Bindable
    public int getNo() {
        return no;
    }

    public void setNo(int no) {
        this.no = no;
    }

    public SearchModel getParent() {
        return parent;
    }

    public void setParent(SearchModel parent) {
        this.parent = parent;
    }

    public SearchRecord(Context context, @LayoutRes int layoutId) {
        super(context, layoutId);
    }

    @Keep
    @Generated(hash = 1628946404)
    public SearchRecord(Long id, String text) {
        super(null, 0);
        this.id = id;
        this.text = text;
    }

    @Keep
    @Generated(hash = 839789598)
    public SearchRecord() {
        super(null, 0);
    }

    @Keep
    @Generated(hash = 683484666)
    public SearchRecord(Long id, String text, long timestamp) {
        super(null, 0);
        this.id = id;
        this.text = text;
        this.timestamp = timestamp;
    }

    public void onClickItem(View view) {
        parent.setSearched(true);
        this.parent.setSearchText(text);
        this.parent.setCurrentPage(1);
        this.parent.load(1);
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }
}
